{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load Dataset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## loading spectrum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(6032, 12103)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "signals = np.loadtxt('data/spectrum.csv', delimiter=';')\n",
    "signals.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## loading labels and features"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>esp_id</th>\n",
       "      <th>label</th>\n",
       "      <th>median(8,13)</th>\n",
       "      <th>rms(98,102)</th>\n",
       "      <th>median(98,102)</th>\n",
       "      <th>peak1x</th>\n",
       "      <th>peak2x</th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>7</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0.002170</td>\n",
       "      <td>0.073935</td>\n",
       "      <td>0.000745</td>\n",
       "      <td>0.04894</td>\n",
       "      <td>0.01040</td>\n",
       "      <td>-0.000253</td>\n",
       "      <td>-6.485689</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0.000290</td>\n",
       "      <td>0.266436</td>\n",
       "      <td>0.002295</td>\n",
       "      <td>0.15950</td>\n",
       "      <td>0.02152</td>\n",
       "      <td>-0.000546</td>\n",
       "      <td>-7.630209</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0.042025</td>\n",
       "      <td>0.171981</td>\n",
       "      <td>0.004265</td>\n",
       "      <td>0.11314</td>\n",
       "      <td>0.02472</td>\n",
       "      <td>-0.003483</td>\n",
       "      <td>-2.293972</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0.000915</td>\n",
       "      <td>0.060911</td>\n",
       "      <td>0.000310</td>\n",
       "      <td>0.03801</td>\n",
       "      <td>0.00534</td>\n",
       "      <td>-0.000960</td>\n",
       "      <td>-6.725640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0.001235</td>\n",
       "      <td>0.105685</td>\n",
       "      <td>0.001320</td>\n",
       "      <td>0.06891</td>\n",
       "      <td>0.00479</td>\n",
       "      <td>-0.000497</td>\n",
       "      <td>-6.407991</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    esp_id   label  median(8,13)  rms(98,102)  median(98,102)   peak1x  \\\n",
       "id                                                                       \n",
       "0        7  Normal      0.002170     0.073935        0.000745  0.04894   \n",
       "1        0  Normal      0.000290     0.266436        0.002295  0.15950   \n",
       "2        4  Normal      0.042025     0.171981        0.004265  0.11314   \n",
       "3        5  Normal      0.000915     0.060911        0.000310  0.03801   \n",
       "4        7  Normal      0.001235     0.105685        0.001320  0.06891   \n",
       "\n",
       "     peak2x         a         b  \n",
       "id                               \n",
       "0   0.01040 -0.000253 -6.485689  \n",
       "1   0.02152 -0.000546 -7.630209  \n",
       "2   0.02472 -0.003483 -2.293972  \n",
       "3   0.00534 -0.000960 -6.725640  \n",
       "4   0.00479 -0.000497 -6.407991  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAkgAAAGfCAYAAACkzS2lAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA2Z0lEQVR4nO3de3hM18LH8V8SuUgYQUk44tJXq1F3WpnqQYmkmnrK0Qt1NErbwwlF2lLvo67nlGpRKqpXUaeqtKWte+raErdU1DVVpZxDoocSl0qG7PePPtmvWUGNTiTTfj/PMw977TVr1l5rZuc3+5L4WZZlCQAAADb/ku4AAABAaUNAAgAAMBCQAAAADAQkAAAAAwEJAADAQEACAAAwEJAAAAAMBCQAAAADAQkAAMBAQAIAADCU8aTyqFGjNHr0aLeyevXqae/evZKk8+fP65lnntHcuXOVl5en+Ph4TZ8+XREREXb9Q4cOqV+/flq9erXKlSunxMREjRs3TmXK/H9X1qxZo+TkZO3atUtRUVEaPny4evXq5dGGFRQU6MiRIypfvrz8/Pw8ei4AACgZlmXp9OnTql69uvz9S/A4juWBkSNHWrfffrt19OhR+/Hjjz/a6/v27WtFRUVZK1eutLZu3WrFxMRYd911l73+woULVoMGDazY2Fhr27Zt1pIlS6ybbrrJGjZsmF3n+++/t0JDQ63k5GRr9+7d1muvvWYFBARYy5Yt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afDgwd7fegAAgMvw6BTbv//9b3Xv3l3Hjx9XlSpVdPfdd2vjxo2qUqWKJGny5Mny9/dX165d3X5RZKGAgAAtWrRI/fr1k9PpVFhYmBITEzVmzBi7Tp06dbR48WINHjxYU6ZMUY0aNfT2228rPj7eS5sMAABwdR4FpLlz5151fUhIiFJSUpSSknLFOrVq1dKSJUuu2k7btm21bds2T7oGAADgNfwtNgAAAAMBCQAAwEBAAgAAMBCQAAAADAQkAAAAAwEJAADAQEACAAAw/Ka/xfZH1mDUcuVd9Cvpblyzg+MTSroLAAD4DI4gAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAACG3xSQxo8fLz8/Pw0aNMguO3/+vJKSklS5cmWVK1dOXbt2VU5OjtvzDh06pISEBIWGhqpq1ap67rnndOHCBbc6a9asUbNmzRQcHKy6desqNTX1t3QVAADgml13QNqyZYveeOMNNWrUyK188ODB+vzzzzV//nytXbtWR44c0V/+8hd7/cWLF5WQkKD8/Hxt2LBBs2bNUmpqqkaMGGHXOXDggBISEnTPPfcoMzNTgwYN0hNPPKHly5dfb3cBAACu2XUFpDNnzqhHjx566623VLFiRbv81KlTeueddzRp0iS1a9dOzZs318yZM7VhwwZt3LhRkrRixQrt3r1b//rXv9SkSRN17NhRY8eOVUpKivLz8yVJM2bMUJ06dTRx4kRFR0erf//+evDBBzV58mQvbDI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AgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgIGABAAAYCAgAQAAGAhIAAAABgISAACAgYAEAABgICABAAAYCEgAAAAGAhIAAICBgAQAAGAgIAEAABgISAAAAAYCEgAAgMGjgPT666+rUaNGcjgccjgccjqdWrp0qb3+/PnzSkpKUuXKlVWuXDl17dpVOTk5bm0cOnRICQkJCg0NVdWqVfXcc8/pwoULbnXWrFmjZs2aKTg4WHXr1lVqaur1byEAAICHPApINWrU0Pjx45WRkaGtW7eqXbt2euCBB7Rr1y5J0uDBg/X5559r/vz5Wrt2rY4cOaK//OUv9vMvXryohIQE5efna8OGDZo1a5ZSU1M1YsQIu86BAweUkJCge+65R5mZmRo0aJCeeOIJLV++3EubDAAAcHVlPKncqVMnt+V//vOfev3117Vx40bVqFFD77zzjubMmaN27dpJkmbOnKno6Ght3LhRMTExWrFihXbv3q0vvvhCERERatKkicaOHauhQ4dq1KhRCgoK0owZM1SnTh1NnDhRkhQdHa2vvvpKkydPVnx8/BX7lpeXp7y8PHs5NzdXkuRyueRyuTzZzKsqbCvY3/JamzeCN8fA1xWOBWPiu5hD38cc+rbinL/S8p7wKCBd6uLFi5o/f77Onj0rp9OpjIwMuVwuxcbG2nVuu+021axZU+np6YqJiVF6eroaNmyoiIgIu058fLz69eunXbt2qWnTpkpPT3dro7DOoEGDrtqfcePGafTo0UXKV6xYodDQ0OvdzCsa26LA620WpyVLlpR0F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TbusUqVKKl++fLH04Y869pfzuw5IsbGxioyM1Lhx465Y5+OPP9btt9+u4OBg1a5dWxMnTnRbX7t2bY0dO1aPPfaYHA6HnnrqKfuox6JFi1SvXj2FhobqwQcf1Llz5zRr1izVrl1bFStW1NNPP62LFy/abc2ePVstWrRQ+fLlFRkZqUcffVTHjh0rtu33NYWnYV555RVVq1ZNlStXVlJSklwul1u906dPq3v37goLC9Of/vQnpaSkuK2fNGmSGjZsqLCwMEVFRenvf/+7zpw5c8XX3b9/vx544AFFRESoXLlyuuOOO/TFF1+41aldu7ZefPFF9e7dW+XLl1fNmjX15ptvutX597//re7du6tSpUoKCwtTixYttGnTJnv9p59+qmbNmikkJEQ333yzRo8erQsXLlzvcHldcHCwIiMj3R4BAQG/Op6jRo1SkyZN3Np69dVXVbt27cu+Tq9evbR27VpNmTLFPlpx4MAB1a1bV6+88opb3czMzKseyVqzZo3uvPNOhYWFKTw8XK1atdIPP/xgr/+1Mffz89Pbb7+tLl26KDQ0VLfccos+++wze/1PP/2kHj16qEqVKipbtqxuueUWzZw5016/Y8cOtWvXTmXLllXlypX11FNPuY1N4Xv6n//8p6pXr6569epdeQJKicL3QVRUlDp37qzY2FilpaVJuvwp7iZNmmjUqFFuZUePHlXHjh1VtmxZ3Xzzzfroo4+KvM7evXt11113KSQkRA0aNNDatWvtdeZpnsJ97vLlyxUdHa1y5crZQa7QhQsX9PTTTys8PFyVK1fW0KFDlZiY6FOndps1a6aoqCh98skndtknn3yimjVrqmnTpnaZeQR2+vTpuuWWWxQSEqKIiAg9+OCD9rply5bp7rvvtsfl/vvv1/79+6/Yh8udYnvrrbcUFRWl0NBQdenSRZMmTXI78l+4D5g9e7Zq166tChUqqFu3bjp9+rRbnwcMGKBBgwapYsWKioiI0FtvvWX/Aujy5curbt26Wrp0qVt/du7cqY4dO6pcuXKKiIhQz5499d///tet3aefflpDhgxRpUqVFBkZ6fZ+LNwPdenSRX5+flfcL13O7zogBQQE6MUXX9Rrr72mf//730XWZ2Rk6OGHH1a3bt20Y8cOjRo1Si+88IJSU1Pd6r3yyitq3Lixtm3bphdeeEGSdO7cOU2dOlVz587VsmXLtGbNGnXp0kVLlizRkiVLNHv2bL3xxhtuOwaXy6WxY8dq+/btWrhwoQ4ePGgfMsUvVq9erf3792v16tWaNWuWUlNTi8zHyy+/bM/H888/r4EDB9o7cEny9/fX1KlTtWvXLs2aNUurVq3SkCFDrviaZ86c0X333aeVK1dq27Ztuvfee9WpUycdOnTIrd7EiRPVokULbdu2TX//+9/Vr18/ZWVl2W20adNG//nPf/TZZ59p+/btGjJkiAoKCiRJX375pR577DENHDhQu3fv1htvvKHU1FT985//9NLIFR9Px/PXTJkyRU6nU08++aR9pKpmzZrq3bu3W/iQpJkzZ6p169aqW7dukXYuXLigzp07q02bNvrmm2+Unp6up556yv7me61jPnr0aD388MP65ptvdN9996lHjx46ceKEJOmFF17Q7t27tXTpUu3Zs0evv/66brrpJknS2bNnFR8fr4oVK2rLli2aP3++vvjiC/Xv39+t/ZUrVyorK0tpaWlatGjRdY9bSdi5c6c2bNigoKAgj573wgsvqGvXrtq+fbt69Oihbt26ac+ePW51nnvuOT3zzDPatm2bnE6nOnXqpOPHj1+xzXPnzumVV17R7NmztW7dOh06dEjPPvusvf6ll17S+++/r5kzZ2r9+vXKzc29rtMqJc38HLz77rtX/QsSW7du1dNPP60xY8YoKytLy5YtU+vWre31Z8+eVXJysrZu3aqVK1fK399fXbp0sfdNv2b9+vXq27evBg4cqMzMTHXo0OGy+639+/dr4cKFWrRokRYtWqS1a9cWucRl1qxZuummm7R582YNGDBA/fr100MPPaS77rpLX3/9teLi4tSzZ0+dO3dOknTy5Em1a9dOTZs21datW7Vs2TLl5OTo4YcfLtJuWFiYNm3apAkTJmjMmDH2z4QtW7ZI+mVfcvToUXv5mli/U4mJidYDDzxgWZZlxcTEWL1797Ysy7IWLFhgFW72o48+anXo0MHtec8995xVv359e7lWrVpW586d3erMnDnTkmR99913dtnf/vY3KzQ01Dp9+rRdFh8fb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w4UTExMbr11lt15MiRq7a3fv169erVS126dFHDhg0VGRmpgwcPetSnRo0aKTMz0752xdSsWTNlZWW5BZDCh79/6f0YXst4VqlSRdnZ2W4/rK72O26kX+6UufQobaH77rtPYWFhev3117Vs2bJf/eEgSU2bNtWwYcO0YcMGNWjQQHPmzJHkvTGvUqWKEhMT9a9//UuvvvqqfXF+dHS0tm/frrNnz9p1169fL39/f5+4GPta+Pv763//9381fPhw/fzzz6pSpYrbUbrc3FwdOHCgyPOu9hm9XJ0LFy4oIyOjSJ1rVaFCBUVERLhdX3Lx4sXL7nN8wb333qv8/Hy5XC7Fx8f/av0yZcooNjZWEyZM0DfffKODBw9q1apVOn78uLKysjR8+HC1b99e0dHRHt/VXa9evSLX7Xh0Hc9v0KxZM+3atUu1a9cu8hn25ItHYGDgZfc3v6b07pm9rGHDhurRo4d92kCSnnnmGa1cuVJjx47Vt99+q1mzZmnatGkef0O8FjVr1lRQUJBee+01ff/99/rss8+K7fdYlEb9+vXTt99+q6efflrffPONsrKyNGnSJH3wwQd65plnPGpr/fr1mjBhgr799lulpKRo/vz5GjhwoCSpbt26crlc9jjPnj1bM2bMuGp7t9xyiz755BNlZmZq+/btevTRRz3+9tG9e3dFRkaqc+fOWr9+vb7//nt9/PHHdiAfMWKE3nvvPY0ePVq7du3Snj17NHfuXA0fPtyj17nRrmU827Ztqx9//FETJkzQ/v37lZKSUuROFFPt2rW1adMmHTx4UP/973/t8Q4ICFCvXr00bNgw3XLLLUVO1VzqwIEDGjZsmNLT0/XDDz9oxYoV2rdvn/1D1htjPmLECH366af67rvvtGvXLi1atMhuv0ePHgoJCVFiYqJ27typ1atXa8CAAerZs6d9quD34KGHHlJAQIBSUlLUrl07zZ49W19++aV27NihxMTEy36ZnD9/vt599119++23GjlypDZv3lzk4vWUlBQtWLBAe/fuVVJSkn766adrCsRXMmDAAI0bN06ffvqpsrKyNHDgQP30008+ebt6QECA9uzZo927d//ql/VFixZp6tSpyszM1A8//KD33ntPBQUFqlevnipWrKjKlSvrzTff1HfffadVq1YpOTnZo74MGDBAS5Ys0aRJk7Rv3z698cYbWrp06Q0Z16SkJJ04cULdu3fXli1btH//fi1fvlyPP/64R4Gndu3aWrlypbKzsz0KiH+YgCRJY8aMcfvB16xZM82bN09z585VgwYNNGLECI0ZM6ZY7iyrUqWKUlNTNX/+fNWvX1/jx48vckvz79nNN9+sdevWae/evYqNjVXLli01b948zZ8/X/fee69HbT3zzDPaunWrmjZtqn/84x+aNGmS/S2rcePGmjRpkl566SU1aNBA77///lV/zYP0y68FqFixou666y516tRJ8fHxatasmUd9CgoK0ooVK1S1alXdd999atiwocaPH2/v3OLj47Vo0SKtWLFCd9xxh2JiYjR58mTVqlXLo9e50a5lPKOjozV9+nSlpKSocePG2rx5869+yXj22WcVEBCg+vXrq0qVKm7XQ/Tp00f5+flXvXNH+uWalL1796pr16669dZb9dRTTykpKUl/+9vfJHlnzIOCgjRs2DA1atRIrVu3VkBAgObOnWu//vLly3XixAndcccdevDBB9W+fXtNmzbtmtv3BWXKlFH//v01YcIEPf/882rTpo3uv/9+JSQkqHPnzm7XBRUaPXq05s6dq0aNGum9997TBx98oPr167vVGT9+vMaPH6/GjRvrq6++0meffXbVa21+zdChQ9W9e3c99thjcjqdKleunOLj40vNKWxPORwOORyOX60XHh6uTz75RO3atVN0dLRmzJihDz74QLfffrv8/f01d+5cZWRkqEGDBho8eLBefvllj/rRqlUrzZgxQ5MmTVLjxo21bNkyDR48+IaMa/Xq1bV+/XpdvHhRcXFxatiwoQYNGqTw8HCPjgJPnDhRaWlpioqKcvt1Cb/Gz/q9nsQF4JO+/PJLtW/fXocPH/5dHYnBjVVQUKDo6Gg9/PDDf6ij9TfCk08+qb179+rLL78s6a4UqzIl3QEAkKS8vDz9+OOPGjVqlB566CHCETxSeJq1TZs2ysvL07Rp03TgwAE9+uijJd01n/fKK6+oQ4cOCgsL09KlSzVr1ixNnz69pLtV7P5Qp9gAlF4ffPCBatWqpZMnT2rChAkl3R34GH9/f6WmpuqOO+5Qq1attGPHDn3xxRfXfeE3/t/mzZvVoUMHNWzYUDNmzNDUqVP1xBNPlHS3ih2n2AAAAAwcQQIAADAQkAAAAAwEJAAAAAMBCQAAwEBAAgAAMBCQAAAADAQkAAAAAwEJAADA8H889eJtO8wXXAAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "features = pd.read_csv('data/features.csv',sep=';', index_col='id')\n",
    "labels = features['label']\n",
    "esp_id = features['esp_id']\n",
    "labels.hist();\n",
    "features.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Cross-validation on models applied to ICTAI2016 features"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from sklearn.model_selection import cross_validate, StratifiedKFold\n",
    "from PredefinedKFold import PredefinedKFold\n",
    "\n",
    "ICTAI2016_features = ['a', 'b', 'real_rotation_hz', 'peak1x', 'peak2x', 'rms(freq-1,freq+1)',\n",
    "                      'median(freq-1,freq+1)', 'median(3,5)']\n",
    "\n",
    "X = features[ICTAI2016_features]\n",
    "\n",
    "rf = RandomForestClassifier(n_estimators=100, max_features=5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## cross-validation using ESP group"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.69874913, 0.44767917, 0.65999974, 0.78918054])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sampler = PredefinedKFold(n_rounds=1) # run 1 round only.\n",
    "scores = cross_validate(rf, X, labels, groups=esp_id, scoring='f1_macro', cv=sampler)\n",
    "scores['test_score']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## cross-validation using StratifiedKFold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.8839406 , 0.86804548, 0.87580565, 0.90267981])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sampler = StratifiedKFold(n_splits=4, shuffle=True) # run 1 round only.\n",
    "scores = cross_validate(rf, X, labels, groups=esp_id, scoring='f1_macro', cv=sampler)\n",
    "scores['test_score']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
